import React, { FC } from 'react'
import { Route } from 'react-router-dom'
import { RouteProps } from 'react-router'
import PrivateRoute from './pravateRoute'
import { routePathMapObj } from './constant'

export interface WrapperRouteProps extends RouteProps {
  /** document title locale id */
  titleId: string
  /** authorization？ */
  auth?: boolean
}

export const routeMap: any = {
  index: 'index',
  collection: 'collection',
  transfer: 'transfer-manager',
  inform: 'inform-admin',
  accept: 'accept-property',
  notify: 'confirm-notification',
  borrow: 'borrow-property',
  self: 'keep-self',
  centralized: 'centralized-storage',
  confirm: 'confirm-borrow',
  receive: 'receive-property',
  handle: 'handle-property',
  return: 'return-property',
  approveList: 'approve-list',
  query: 'inquire-property',
  standbook: 'inquire-standbook',
  law: 'inquire-law',
  accessibility: 'void-certificate',
  uploadfile: 'updating-files',
  dashboard: 'dashboard',
  uploaditems: 'upload-items',
  take: 'confirm-take',
  camera: 'camera',
  depository: 'depository-information',
  qa: 'qa'
}

export const routeCollect: any = {
  index: routePathMapObj['index'],
  collection: routePathMapObj['collection'],
  transfer: routePathMapObj['transfer'],
  inform: routePathMapObj['inform'],
  accept: routePathMapObj['accept'],
  notify: routePathMapObj['notify'],
  borrow: routePathMapObj['borrow'],
  self: routePathMapObj['self'],
  centralized: routePathMapObj['centralized'],
  confirm: routePathMapObj['confirm'],
  receive: routePathMapObj['receive'],
  handle: routePathMapObj['handle'],
  return: routePathMapObj['return'],
  approveList: routePathMapObj['approveList'],
  query: routePathMapObj['query'],
  standbook: routePathMapObj['standbook'],
  law: routePathMapObj['law'],
  accessibility: routePathMapObj['accessibility'],
  uploadfile: routePathMapObj['uploadfile'],
  dashboard: routePathMapObj['dashboard'],
  uploaditems: routePathMapObj['uploaditems'],
  take: routePathMapObj['take'],
  camera: routePathMapObj['camera'],
  depository: routePathMapObj['depository'],
  qa: routePathMapObj['qa']
}

export const routeMapText: any = new Map([
  [routePathMapObj['index'], '首页'],
  [routePathMapObj['collection'], '手工采集涉案财物'],
  [routePathMapObj['transfer'], '移送专管员'],
  [routePathMapObj['inform'], '告知专管员'],
  [routePathMapObj['accept'], '接收物品'],
  [routePathMapObj['notify'], '确认告知'],
  [routePathMapObj['take'], '确认处理'],
  [routePathMapObj['borrow'], '借用涉案财物'],
  [routePathMapObj['self'], '自行保管'],
  [routePathMapObj['centralized'], '集中保管'],
  [routePathMapObj['confirm'], '确认借用涉案财物'],
  [routePathMapObj['receive'], '领取涉案财物'],
  [routePathMapObj['handle'], '处理涉案财物'],
  [routePathMapObj['return'], '归还涉案财物'],
  [routePathMapObj['approveList'], '借用审批'],
  [routePathMapObj['query'], '查询涉案财物'],
  [routePathMapObj['standbook'], '查询台账信息'],
  [routePathMapObj['law'], '查询法律文书'],
  [routePathMapObj['accessibility'], '辅助功能'],
  [routePathMapObj['qa'], '答疑专栏'],
  [routePathMapObj['uploadfile'], '附件上传'],
  // [routePathMapObj['dashboard'], '数据分析'],
  [routePathMapObj['uploaditems'], '上传物品照片'],
  [routePathMapObj['camera'], '拍照功能'],
  [routePathMapObj['depository'], '存放地信息登记'],
  [routePathMapObj['qa'], '答疑专栏']
])

const WrapperRouteComponent: FC<WrapperRouteProps> = ({ titleId, auth, ...props }) => {
  const WitchRoute = auth ? PrivateRoute : Route
  if (titleId) {
    document.title = titleId
  }
  return <WitchRoute {...props} />
}

export default WrapperRouteComponent
